package com.work.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        String tenantId = AuthUtil.getTenantId();
        if (!StringUtil.isBlank(tenantId)) {
            this.strictInsertFill(metaObject, "tenantId", () -> tenantId, String.class);
        }
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
